#include<iostream>
using namespace std;
#include<vector>

class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int left = 0, right = 0;
        int sum = 0, len = INT_MAX;
        int n = nums.size();
        while (right < n)
        {
            sum += nums[right];
            right++;
            while (sum >= target)
            {
                sum -= nums[left];
                left++;
                len = min(len, right - left + 1);
            }
        }
        if (len == INT_MAX)
            return 0;
        return len;
    }
};
int main()
{
    vector<int> a = { 5,1,3,5,10,7,4,9,2,8 };
    Solution s;
    s.minSubArrayLen(15, a);

    return 0;
}